from get_data import GetData
from action_method import ActionMethod
from uitls.server import Server
from uitls.opera_excel import OperExcel
class RunMain:
    def run_method(self):
        server = Server()
        server.main()
        data = GetData()
        oper=OperExcel()
        action_method = ActionMethod()
        lines = data.get_case_lines()
        for i in range(1, lines):
            handle_step = data.get_hanle_step(i)#操作步骤
            element_key = data.get_element_key(i)#操作元素
            hand_value = data.get_handle_value(i)#操作值
            expect_key = data.get_expect_element(i)#预期元素
            expect_step = data.get_expect_handle(i)#预期步骤
            # 不是所有元素的值都有值，没有的话，就返回none了
            excute_method = getattr(action_method, handle_step)
            if element_key != None:
                excute_method(element_key, hand_value)
            else:
                excute_method(hand_value)
            if expect_step != None:
                expect_result = getattr(action_method, expect_step)
                result=expect_result(expect_key)
                if result:
                    print('-----------调用pass----------------')
                    oper.write_result_value(row=i,value='pass')
                else:
                    print('------------调用fail--------------------')
                    oper.write_result_value(row=i,value='fail')
        oper.save_kuai8_result()
        print('执行完成。。。。。。。。。。。。。。。')


if __name__ == '__main__':
    run_main = RunMain()
    run_main.run_method()
